package HW1;

//学生对象类，包括无参，有参的构造器
public class Student {
    private String id;
    private String name;
    private int age;

    public Student() {
    }

    public Student(String id, String name, int age) throws StudentAgeException, StudentIDException {
     setAge(age);
     setName(name);
     setId(id);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) throws StudentIDException {


        if(!id.equals("0")){
            this.id = id;
        }else{

                throw new StudentIDException();

        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws StudentAgeException {

        if(age>0 && age<100){
            this.age = age;
        }else{

                throw new StudentAgeException();

        }
    }

//    public void showInfo(){
//        System.out.println("学生姓名：" + getName() +
//                "学号：" + getId() +
//                "年龄：" + getAge());
//    }
}
